package plus;

import java.util.Arrays;

public class TS_Formal extends TypeSym {
	// This is a perfectly good place to apply flyweight pattern...
	private static TS_Formal[] stash = new TS_Formal[0]; 
	static TS_Formal get(int index) {
		if (index >= stash.length) {
			int new_len = index+stash.length+3;
			stash = Arrays.copyOf(stash, new_len);
		}
		if (stash[index] == null) stash[index] = new TS_Formal(index);
		return stash[index];
	}
	
	final Type tvar;
	private TS_Formal(int index) {
		this.tvar = Type.fresh(new S_Formal(index));
	}

	@Override public Type constructWith(Type[] actuals) {
		if (null != actuals) throw new Gripe("Can't provide formal type parameters to a formal type parameter.");
		return tvar;
	}

}
